echo Merging entities segment files...
cat entities_*.json > merged_entities.json

echo Merging instances segment files...
cat instances_*.json > merged_instances.json

echo Transforming JSON to TSV...
python rfjson2tsv.py --instance_input_file merged_instances.json --entity_input_file merged_entities.json --instance_output_file instances.tsv --entity_output_file entities_unsorted.tsv

echo Sorting merged entities...
sort --key=1,2 --unique entities_unsorted.tsv > entities_sorted.tsv
